package edu.dongthang.screens;

import edu.dongthang.screens.R;
import java.util.Locale;
import edu.dongthang.screens.MainMenu;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;

public class SplashScreen extends Activity{
	private static int SPLASH_TIME_OUT = 1500;
	SettingScreen st;
	SharedPreferences pref;
	Editor editor;
	public String lang;
	Configuration config1;
	public static final String PREFS_NAME = "MyPrefsFile";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		
		//lay language trong csdl, và load gói ngôn ngữ tương ứng
		pref = getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
		editor = pref.edit();
		lang = pref.getString("language","en").toString();
		Locale la = new Locale(lang);
		Locale.setDefault(la);
		//updateResourse();
		config1 = new Configuration();
		config1.locale = la;
		getBaseContext().getResources().updateConfiguration(config1,
				getBaseContext().getResources().getDisplayMetrics());
		
		
		//delay 4 giây sau đó mở màn hình mainmenu
		new Handler().postDelayed(new Runnable() {
			public void run() {
				Intent i = new Intent(SplashScreen.this, IntroScreen.class);
				startActivity(i);
				finish();
			}
		}, SPLASH_TIME_OUT);
	}
	
}
